/*
 * Amazon Ads API - Sponsored Products
 * Use the Amazon Ads API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the [Sponsored Products Support Center](https://advertising.amazon.com/help?entityId=ENTITY3CWETCZD9HEG2#GWGFKPEWVWG2CLUJ). For onboarding information, see the [account setup](setting-up/account-setup) topic.<br/><br/> 
 *
 * The version of the OpenAPI document: 2.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


package org.openapitools.client.api;

import org.openapitools.client.ApiCallback;
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.ApiResponse;
import org.openapitools.client.Configuration;
import org.openapitools.client.Pair;
import org.openapitools.client.ProgressRequestBody;
import org.openapitools.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;


import java.math.BigDecimal;
import org.openapitools.client.model.BrandResponse;
import org.openapitools.client.model.CreateTargetingClause;
import org.openapitools.client.model.Error;
import org.openapitools.client.model.InlineObject2;
import org.openapitools.client.model.ProductRecommendationsResponse;
import org.openapitools.client.model.TargetingClause;
import org.openapitools.client.model.TargetingClauseEx;
import org.openapitools.client.model.TargetingClauseResponse;
import org.openapitools.client.model.UpdateTargetingClause;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ProductTargetingApi {
    private ApiClient localVarApiClient;

    public ProductTargetingApi() {
        this(Configuration.getDefaultApiClient());
    }

    public ProductTargetingApi(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return localVarApiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.localVarApiClient = apiClient;
    }

    /**
     * Build call for archiveTargetingClause
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call archiveTargetingClauseCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/{targetId}"
            .replaceAll("\\{" + "targetId" + "\\}", localVarApiClient.escapeString(targetId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call archiveTargetingClauseValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling archiveTargetingClause(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling archiveTargetingClause(Async)");
        }
        
        // verify the required parameter 'targetId' is set
        if (targetId == null) {
            throw new ApiException("Missing the required parameter 'targetId' when calling archiveTargetingClause(Async)");
        }
        

        okhttp3.Call localVarCall = archiveTargetingClauseCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        return localVarCall;

    }

    /**
     * Archives a targeting clause.
     * Set the &#x60;status&#x60; of a targeting clause to &#x60;archived&#x60;. Note that once a targeting clause &#x60;status&#x60; is set to &#x60;archived&#x60;, it cannot be changed.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return TargetingClauseResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public TargetingClauseResponse archiveTargetingClause(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        ApiResponse<TargetingClauseResponse> localVarResp = archiveTargetingClauseWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId);
        return localVarResp.getData();
    }

    /**
     * Archives a targeting clause.
     * Set the &#x60;status&#x60; of a targeting clause to &#x60;archived&#x60;. Note that once a targeting clause &#x60;status&#x60; is set to &#x60;archived&#x60;, it cannot be changed.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return ApiResponse&lt;TargetingClauseResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<TargetingClauseResponse> archiveTargetingClauseWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        okhttp3.Call localVarCall = archiveTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, null);
        Type localVarReturnType = new TypeToken<TargetingClauseResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Archives a targeting clause. (asynchronously)
     * Set the &#x60;status&#x60; of a targeting clause to &#x60;archived&#x60;. Note that once a targeting clause &#x60;status&#x60; is set to &#x60;archived&#x60;, it cannot be changed.
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call archiveTargetingClauseAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback<TargetingClauseResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = archiveTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        Type localVarReturnType = new TypeToken<TargetingClauseResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for createTargetRecommendations
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param inlineObject2  (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createTargetRecommendationsCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, InlineObject2 inlineObject2, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = inlineObject2;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/productRecommendations";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createTargetRecommendationsValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, InlineObject2 inlineObject2, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling createTargetRecommendations(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling createTargetRecommendations(Async)");
        }
        

        okhttp3.Call localVarCall = createTargetRecommendationsCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, inlineObject2, _callback);
        return localVarCall;

    }

    /**
     * Gets a list of recommended products for targeting.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param inlineObject2  (optional)
     * @return ProductRecommendationsResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public ProductRecommendationsResponse createTargetRecommendations(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, InlineObject2 inlineObject2) throws ApiException {
        ApiResponse<ProductRecommendationsResponse> localVarResp = createTargetRecommendationsWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, inlineObject2);
        return localVarResp.getData();
    }

    /**
     * Gets a list of recommended products for targeting.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param inlineObject2  (optional)
     * @return ApiResponse&lt;ProductRecommendationsResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<ProductRecommendationsResponse> createTargetRecommendationsWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, InlineObject2 inlineObject2) throws ApiException {
        okhttp3.Call localVarCall = createTargetRecommendationsValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, inlineObject2, null);
        Type localVarReturnType = new TypeToken<ProductRecommendationsResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Gets a list of recommended products for targeting. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param inlineObject2  (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createTargetRecommendationsAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, InlineObject2 inlineObject2, final ApiCallback<ProductRecommendationsResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = createTargetRecommendationsValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, inlineObject2, _callback);
        Type localVarReturnType = new TypeToken<ProductRecommendationsResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for createTargetingClauses
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param createTargetingClause A list of targeting clauses. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createTargetingClausesCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<CreateTargetingClause> createTargetingClause, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = createTargetingClause;

        // create path and map variables
        String localVarPath = "/v2/sp/targets";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call createTargetingClausesValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<CreateTargetingClause> createTargetingClause, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling createTargetingClauses(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling createTargetingClauses(Async)");
        }
        

        okhttp3.Call localVarCall = createTargetingClausesCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, createTargetingClause, _callback);
        return localVarCall;

    }

    /**
     * Creates one or more targeting expressions.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param createTargetingClause A list of targeting clauses. (optional)
     * @return List&lt;TargetingClauseResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public List<TargetingClauseResponse> createTargetingClauses(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<CreateTargetingClause> createTargetingClause) throws ApiException {
        ApiResponse<List<TargetingClauseResponse>> localVarResp = createTargetingClausesWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, createTargetingClause);
        return localVarResp.getData();
    }

    /**
     * Creates one or more targeting expressions.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param createTargetingClause A list of targeting clauses. (optional)
     * @return ApiResponse&lt;List&lt;TargetingClauseResponse&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<List<TargetingClauseResponse>> createTargetingClausesWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<CreateTargetingClause> createTargetingClause) throws ApiException {
        okhttp3.Call localVarCall = createTargetingClausesValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, createTargetingClause, null);
        Type localVarReturnType = new TypeToken<List<TargetingClauseResponse>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Creates one or more targeting expressions. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param createTargetingClause A list of targeting clauses. (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call createTargetingClausesAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<CreateTargetingClause> createTargetingClause, final ApiCallback<List<TargetingClauseResponse>> _callback) throws ApiException {

        okhttp3.Call localVarCall = createTargetingClausesValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, createTargetingClause, _callback);
        Type localVarReturnType = new TypeToken<List<TargetingClauseResponse>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getBrandRecommendations
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param keyword A keyword for which to get recommended brands. (optional)
     * @param categoryId Gets the top 50 brands for the specified category identifier. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getBrandRecommendationsCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String keyword, BigDecimal categoryId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/brands";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (keyword != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("keyword", keyword));
        }

        if (categoryId != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("categoryId", categoryId));
        }

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getBrandRecommendationsValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String keyword, BigDecimal categoryId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling getBrandRecommendations(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling getBrandRecommendations(Async)");
        }
        

        okhttp3.Call localVarCall = getBrandRecommendationsCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, keyword, categoryId, _callback);
        return localVarCall;

    }

    /**
     * Get recommended brands for Sponsored Products.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param keyword A keyword for which to get recommended brands. (optional)
     * @param categoryId Gets the top 50 brands for the specified category identifier. (optional)
     * @return BrandResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public BrandResponse getBrandRecommendations(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String keyword, BigDecimal categoryId) throws ApiException {
        ApiResponse<BrandResponse> localVarResp = getBrandRecommendationsWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, keyword, categoryId);
        return localVarResp.getData();
    }

    /**
     * Get recommended brands for Sponsored Products.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param keyword A keyword for which to get recommended brands. (optional)
     * @param categoryId Gets the top 50 brands for the specified category identifier. (optional)
     * @return ApiResponse&lt;BrandResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<BrandResponse> getBrandRecommendationsWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String keyword, BigDecimal categoryId) throws ApiException {
        okhttp3.Call localVarCall = getBrandRecommendationsValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, keyword, categoryId, null);
        Type localVarReturnType = new TypeToken<BrandResponse>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get recommended brands for Sponsored Products. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param keyword A keyword for which to get recommended brands. (optional)
     * @param categoryId Gets the top 50 brands for the specified category identifier. (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 207 </td><td> Multi-status. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getBrandRecommendationsAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, String keyword, BigDecimal categoryId, final ApiCallback<BrandResponse> _callback) throws ApiException {

        okhttp3.Call localVarCall = getBrandRecommendationsValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, keyword, categoryId, _callback);
        Type localVarReturnType = new TypeToken<BrandResponse>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getTargetingClause
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getTargetingClauseCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/{targetId}"
            .replaceAll("\\{" + "targetId" + "\\}", localVarApiClient.escapeString(targetId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getTargetingClauseValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling getTargetingClause(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling getTargetingClause(Async)");
        }
        
        // verify the required parameter 'targetId' is set
        if (targetId == null) {
            throw new ApiException("Missing the required parameter 'targetId' when calling getTargetingClause(Async)");
        }
        

        okhttp3.Call localVarCall = getTargetingClauseCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        return localVarCall;

    }

    /**
     * Get a targeting clause specified by identifier.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return TargetingClause
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public TargetingClause getTargetingClause(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        ApiResponse<TargetingClause> localVarResp = getTargetingClauseWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId);
        return localVarResp.getData();
    }

    /**
     * Get a targeting clause specified by identifier.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return ApiResponse&lt;TargetingClause&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<TargetingClause> getTargetingClauseWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        okhttp3.Call localVarCall = getTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, null);
        Type localVarReturnType = new TypeToken<TargetingClause>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get a targeting clause specified by identifier. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getTargetingClauseAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback<TargetingClause> _callback) throws ApiException {

        okhttp3.Call localVarCall = getTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        Type localVarReturnType = new TypeToken<TargetingClause>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for getTargetingClauseEx
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getTargetingClauseExCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/extended/{targetId}"
            .replaceAll("\\{" + "targetId" + "\\}", localVarApiClient.escapeString(targetId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call getTargetingClauseExValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling getTargetingClauseEx(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling getTargetingClauseEx(Async)");
        }
        
        // verify the required parameter 'targetId' is set
        if (targetId == null) {
            throw new ApiException("Missing the required parameter 'targetId' when calling getTargetingClauseEx(Async)");
        }
        

        okhttp3.Call localVarCall = getTargetingClauseExCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        return localVarCall;

    }

    /**
     * Get a targeting clause specified by identifier.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return TargetingClauseEx
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public TargetingClauseEx getTargetingClauseEx(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        ApiResponse<TargetingClauseEx> localVarResp = getTargetingClauseExWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId);
        return localVarResp.getData();
    }

    /**
     * Get a targeting clause specified by identifier.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @return ApiResponse&lt;TargetingClauseEx&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<TargetingClauseEx> getTargetingClauseExWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId) throws ApiException {
        okhttp3.Call localVarCall = getTargetingClauseExValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, null);
        Type localVarReturnType = new TypeToken<TargetingClauseEx>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Get a targeting clause specified by identifier. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param targetId The target identifier. (required)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call getTargetingClauseExAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal targetId, final ApiCallback<TargetingClauseEx> _callback) throws ApiException {

        okhttp3.Call localVarCall = getTargetingClauseExValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, targetId, _callback);
        Type localVarReturnType = new TypeToken<TargetingClauseEx>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for listTargetingClauses
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listTargetingClausesCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (startIndex != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("startIndex", startIndex));
        }

        if (count != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("count", count));
        }

        if (stateFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("stateFilter", stateFilter));
        }

        if (campaignIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("campaignIdFilter", campaignIdFilter));
        }

        if (adGroupIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("adGroupIdFilter", adGroupIdFilter));
        }

        if (targetIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("targetIdFilter", targetIdFilter));
        }

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call listTargetingClausesValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling listTargetingClauses(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling listTargetingClauses(Async)");
        }
        

        okhttp3.Call localVarCall = listTargetingClausesCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, _callback);
        return localVarCall;

    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @return List&lt;TargetingClause&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public List<TargetingClause> listTargetingClauses(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter) throws ApiException {
        ApiResponse<List<TargetingClause>> localVarResp = listTargetingClausesWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter);
        return localVarResp.getData();
    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @return ApiResponse&lt;List&lt;TargetingClause&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<List<TargetingClause>> listTargetingClausesWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter) throws ApiException {
        okhttp3.Call localVarCall = listTargetingClausesValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, null);
        Type localVarReturnType = new TypeToken<List<TargetingClause>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listTargetingClausesAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback<List<TargetingClause>> _callback) throws ApiException {

        okhttp3.Call localVarCall = listTargetingClausesValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, _callback);
        Type localVarReturnType = new TypeToken<List<TargetingClause>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for listTargetingClausesEx
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listTargetingClausesExCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/v2/sp/targets/extended";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (startIndex != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("startIndex", startIndex));
        }

        if (count != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("count", count));
        }

        if (stateFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("stateFilter", stateFilter));
        }

        if (campaignIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("campaignIdFilter", campaignIdFilter));
        }

        if (adGroupIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("adGroupIdFilter", adGroupIdFilter));
        }

        if (targetIdFilter != null) {
            localVarQueryParams.addAll(localVarApiClient.parameterToPair("targetIdFilter", targetIdFilter));
        }

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call listTargetingClausesExValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling listTargetingClausesEx(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling listTargetingClausesEx(Async)");
        }
        

        okhttp3.Call localVarCall = listTargetingClausesExCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, _callback);
        return localVarCall;

    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @return List&lt;TargetingClauseEx&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public List<TargetingClauseEx> listTargetingClausesEx(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter) throws ApiException {
        ApiResponse<List<TargetingClauseEx>> localVarResp = listTargetingClausesExWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter);
        return localVarResp.getData();
    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @return ApiResponse&lt;List&lt;TargetingClauseEx&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<List<TargetingClauseEx>> listTargetingClausesExWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter) throws ApiException {
        okhttp3.Call localVarCall = listTargetingClausesExValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, null);
        Type localVarReturnType = new TypeToken<List<TargetingClauseEx>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Gets a list of targeting clauses filtered by specified criteria. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param startIndex 0-indexed record offset for the result set. (optional, default to 0)
     * @param count Number of records to include in the paged response. Defaults to max page size. (optional)
     * @param stateFilter Restricts results to resources with state within the specified comma-separated list. (optional)
     * @param campaignIdFilter A comma-delimited list of campaign identifiers. (optional)
     * @param adGroupIdFilter Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list. (optional)
     * @param targetIdFilter A comma-delimited list of target identifiers. (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call listTargetingClausesExAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, BigDecimal startIndex, BigDecimal count, String stateFilter, String campaignIdFilter, String adGroupIdFilter, String targetIdFilter, final ApiCallback<List<TargetingClauseEx>> _callback) throws ApiException {

        okhttp3.Call localVarCall = listTargetingClausesExValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, startIndex, count, stateFilter, campaignIdFilter, adGroupIdFilter, targetIdFilter, _callback);
        Type localVarReturnType = new TypeToken<List<TargetingClauseEx>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
    /**
     * Build call for updateTargetingClause
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param updateTargetingClause A list of targeting clauses with updated values. (optional)
     * @param _callback Callback for upload/download progress
     * @return Call to execute
     * @throws ApiException If fail to serialize the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateTargetingClauseCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<UpdateTargetingClause> updateTargetingClause, final ApiCallback _callback) throws ApiException {
        Object localVarPostBody = updateTargetingClause;

        // create path and map variables
        String localVarPath = "/v2/sp/targets";

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
        Map<String, String> localVarHeaderParams = new HashMap<String, String>();
        Map<String, String> localVarCookieParams = new HashMap<String, String>();
        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        if (amazonAdvertisingAPIClientId != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-ClientId", localVarApiClient.parameterToString(amazonAdvertisingAPIClientId));
        }

        if (amazonAdvertisingAPIScope != null) {
            localVarHeaderParams.put("Amazon-Advertising-API-Scope", localVarApiClient.parameterToString(amazonAdvertisingAPIScope));
        }

        final String[] localVarAccepts = {
            "application/json"
        };
        final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null) {
            localVarHeaderParams.put("Accept", localVarAccept);
        }

        final String[] localVarContentTypes = {
            "application/json"
        };
        final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        String[] localVarAuthNames = new String[] { "bearer" };
        return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
    }

    @SuppressWarnings("rawtypes")
    private okhttp3.Call updateTargetingClauseValidateBeforeCall(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<UpdateTargetingClause> updateTargetingClause, final ApiCallback _callback) throws ApiException {
        
        // verify the required parameter 'amazonAdvertisingAPIClientId' is set
        if (amazonAdvertisingAPIClientId == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIClientId' when calling updateTargetingClause(Async)");
        }
        
        // verify the required parameter 'amazonAdvertisingAPIScope' is set
        if (amazonAdvertisingAPIScope == null) {
            throw new ApiException("Missing the required parameter 'amazonAdvertisingAPIScope' when calling updateTargetingClause(Async)");
        }
        

        okhttp3.Call localVarCall = updateTargetingClauseCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, updateTargetingClause, _callback);
        return localVarCall;

    }

    /**
     * Updates one or more targeting clauses.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param updateTargetingClause A list of targeting clauses with updated values. (optional)
     * @return List&lt;TargetingClauseResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public List<TargetingClauseResponse> updateTargetingClause(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<UpdateTargetingClause> updateTargetingClause) throws ApiException {
        ApiResponse<List<TargetingClauseResponse>> localVarResp = updateTargetingClauseWithHttpInfo(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, updateTargetingClause);
        return localVarResp.getData();
    }

    /**
     * Updates one or more targeting clauses.
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param updateTargetingClause A list of targeting clauses with updated values. (optional)
     * @return ApiResponse&lt;List&lt;TargetingClauseResponse&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public ApiResponse<List<TargetingClauseResponse>> updateTargetingClauseWithHttpInfo(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<UpdateTargetingClause> updateTargetingClause) throws ApiException {
        okhttp3.Call localVarCall = updateTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, updateTargetingClause, null);
        Type localVarReturnType = new TypeToken<List<TargetingClauseResponse>>(){}.getType();
        return localVarApiClient.execute(localVarCall, localVarReturnType);
    }

    /**
     * Updates one or more targeting clauses. (asynchronously)
     * 
     * @param amazonAdvertisingAPIClientId The identifier of a client associated with a \&quot;Login with Amazon\&quot; developer account. (required)
     * @param amazonAdvertisingAPIScope The identifier of a profile associated with the advertiser account. Use &#x60;GET&#x60; method on Profiles resource to list profiles associated with the access token passed in the HTTP Authorization header. (required)
     * @param updateTargetingClause A list of targeting clauses with updated values. (optional)
     * @param _callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     * @http.response.details
     <table summary="Response Details" border="1">
        <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
        <tr><td> 200 </td><td> Success. </td><td>  -  </td></tr>
        <tr><td> 401 </td><td> Unauthorized. </td><td>  -  </td></tr>
        <tr><td> 404 </td><td> The requested resource was not found. </td><td>  -  </td></tr>
     </table>
     */
    public okhttp3.Call updateTargetingClauseAsync(String amazonAdvertisingAPIClientId, String amazonAdvertisingAPIScope, List<UpdateTargetingClause> updateTargetingClause, final ApiCallback<List<TargetingClauseResponse>> _callback) throws ApiException {

        okhttp3.Call localVarCall = updateTargetingClauseValidateBeforeCall(amazonAdvertisingAPIClientId, amazonAdvertisingAPIScope, updateTargetingClause, _callback);
        Type localVarReturnType = new TypeToken<List<TargetingClauseResponse>>(){}.getType();
        localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
        return localVarCall;
    }
}
